layui.use(['table','layer'], function(){
  	var table = layui.table;
  	var layer = layui.layer;
  	var $ = layui.$;
  	/*@初始化table*/
	table.render({
	    elem: '#table-list',
	    url: '/repair/repair/get_repair', //数据接口
	    page: true, //开启分页
	    where: {ty: 'all'},
	    cols: [[ //表头
	    	{field: 'repair_id', title: '序号'},
	    	{field: 'repair_sn', title: '维修编号', edit: 'text'},
	    	{field: 'addtime', title: '订单时间'},
	    	{field: 'goods_name', title: '设备名称'},
	    	{field: 'goods_name', title: '维修门店'},
	    	{field: 'imei', title: 'IMEI'},
	    	{field: 'sn', title: 'S/N'},
	    	{title: '操作', align:'center', width: 300,toolbar: '#table-btn'},
	    ]]
	});
	/*@监听工具*/
	table.on('tool(list)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
	  	var data = obj.data; //获得当前行数据
	  	var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
	  	var tr = obj.tr; //获得当前行 tr 的DOM对象
	  	if(layEvent === 'copy'){ //复制
	    	window.parent.$("input[name='username']").val(data.username);
	    	window.parent.$("input[name='nkname']").val(data.nkname);
	    	window.parent.$("input[name='phone']").val(data.phone);
	    	window.parent.$("input[name='spare_phone']").val(data.spare_phone);
	    	window.parent.$("input[name='user_sn']").val(data.user_sn);
	    	var user_info = '<span class="chakan span_nav" style="cursor:pointer;" onclick="xadmin.open(\'客户详情\',\'/user/user/details/ids/'+data.user_sn+'\')">'+data.user_sn+'</span>';
	    	window.parent.$("#user-sn").html(user_info);
	    	xadmin.close();
	  	}
	});
  
});